package com.kaven.activity;

import android.content.Intent;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

import com.kaven.R;
import com.neusmart.common.activity.BaseActivity;

/**
 * Created by keven on 2016/3/21.
 */
public class StartActivity  extends BaseActivity implements View.OnClickListener{
    private View view;

    /*
       渐变启始页
    * */
    @Override
    protected int getLayoutResID() {
        return R.layout.activity_start;
    }

    @Override
    protected void init() {
        //Inflate()或可理解为“隐性膨胀”，隐性摆放在view里，inflate()前只是获得控件，但没有大小没有在View里占据空间，inflate()后有一定大小，只是出于隐藏状态
        view = View.inflate(this, R.layout.activity_start, null);
        setContentView(view);
        initView();
    }

    public void initView(){
        //渐变展示启动屏
        AlphaAnimation animation = new AlphaAnimation(0.3f,1.0f);
        //设置动画持续时间
        animation.setDuration(2000);
       // * 常用方法
        //animation.setRepeatCount(int repeatCount);//设置重复次数
        //animation.setFillAfter(boolean);//动画执行完后是否停留在执行完的状态
        //animation.setStartOffset(long startOffset);//执行前的等待时间
        view.startAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
                redirectTo();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}
        });
    }

    /*
     * 跳转到...
     */
    private void redirectTo(){
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    public void onClick(View v) {
    }
}
